package com.zhn.evsi.client;

import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.annotation.*;

@BaseRequest(baseURL = "${eveOAuth}${eveOAuthSns}")
@Retry(maxRetryCount = "3", maxRetryInterval = "1000")
public interface OAuthClient {

    /**
     * 第一次授权请求
     * */
    @Request(url = "/token",
            headers = {
                    "Authorization: ${authorization}"
            },
            type = "POST")
    JSONObject oauthToken(@Var("authorization") String authorization, @JSONBody("grant_type") String grant_type, @JSONBody("code") String code);

    /**
     * 获取角色信息
     * */
    @Request(url = "/verify",
            headers = {
                    "Authorization: ${authorization}"
            },
            type = "GET")
    JSONObject verify(@Var("authorization") String authToken);

    /**
     * 通过refresh_token获取access_token
     * */
    @Request(url = "/token",
            headers = {
                    "Authorization: ${authorization}"
            },
            type = "POST")
    JSONObject oauthTokenV2(@Var("authorization") String authorization, @JSONBody("grant_type") String grant_type, @JSONBody("refresh_token") String refreshToken);
}
